//package com.lagou.intercepter;
//
//import feign.RequestInterceptor;
//import feign.RequestTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.Enumeration;
//
////@Component
//public class HeaderRequestInterceptor implements RequestInterceptor {
//
//    @Override
//    public void apply(RequestTemplate requestTemplate) {
//        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder
//                .getRequestAttributes();
//        if (attributes != null) {
//            HttpServletRequest request = attributes.getRequest();
//            Enumeration<String> headerNames = request.getHeaderNames();
//            if (headerNames != null) {
//                while (headerNames.hasMoreElements()) {
//                    String name = headerNames.nextElement();
//                    String values = request.getHeader(name);
//                    String token_1 = "";
////                    if(StringUtils.isNotEmpty(values)){
////                        JSONObject jsonObject = JSON.parseObject(values);
////                         token_1 = jsonObject.get("token")==null?"":jsonObject.get("token").toString();
////                    }
//                    Object tokenObj = request.getSession().getAttribute("token");
////                    if(name.equals("cookie")){
//                    requestTemplate.header("token", tokenObj == null ? "" : tokenObj.toString());
////                    }
//                }
//            }
//        }
//    }
//}
